class FinishedOut {
  String? id;
  String? name;
  String? createDateStart;
  String? createDateEnd;
  String? productorderno;
  String? workshopId;
  String? locationId;
  String? locationName;
  String? workOrderId;
  String? productName;
  String? productCode;
  String? productstyle;
  String? batchno;
  String? stockqty;
  String? unitname;
  String? createUid;
  String? createDate;
  String? warehouseId;
  String? writeUid;
  String? writeDate;
  String? moveType;
  String? loaddate;
  String? contractid;
  String? escortcode;
  String? dateDone;
  String? pickingTypeId;
  String? pickingTypeName;
  List? detaileds;

  FinishedOut({
    this.id,
    this.name,
    this.createDateStart,
    this.createDateEnd,
    this.productorderno,
    this.workshopId,
    this.locationId,
    this.locationName,
    this.workOrderId,
    this.productName,
    this.productCode,
    this.productstyle,
    this.batchno,
    this.dateDone,
    this.stockqty,
    this.unitname,
    this.createUid,
    this.createDate,
    this.warehouseId,
    this.writeUid,
    this.writeDate,
    this.moveType,
    this.loaddate,
    this.contractid,
    this.escortcode,
    this.pickingTypeId,
    this.pickingTypeName,
    this.detaileds,
  });

  FinishedOut copyWith({
    String? id,
    String? createDateStart,
    String? createDateEnd,
    String? productorderno,
    String? workshopId,
    String? locationId,
    String? workOrderId,
    String? productName,
    String? productCode,
    String? productstyle,
    String? batchno,
    String? stockqty,
    String? unitname,
    String? createUid,
    String? createDate,
    String? warehouseId,
    String? writeUid,
    String? writeDate,
    String? moveType,
    String? loaddate,
  }) {
    return new FinishedOut(
      id: id ?? this.id,
      createDateStart: createDateStart ?? this.createDateStart,
      createDateEnd: createDateEnd ?? this.createDateEnd,
      productorderno: productorderno ?? this.productorderno,
      workshopId: workshopId ?? this.workshopId,
      locationId: locationId ?? this.locationId,
      workOrderId: workOrderId ?? this.workOrderId,
      productName: productName ?? this.productName,
      productCode: productCode ?? this.productCode,
      productstyle: productstyle ?? this.productstyle,
      batchno: batchno ?? this.batchno,
      stockqty: stockqty ?? this.stockqty,
      unitname: unitname ?? this.unitname,
      createUid: createUid ?? this.createUid,
      createDate: createDate ?? this.createDate,
      warehouseId: warehouseId ?? this.warehouseId,
      writeUid: writeUid ?? this.writeUid,
      writeDate: writeDate ?? this.writeDate,
      loaddate: loaddate ?? this.loaddate,
      moveType: moveType ?? this.moveType,
    );
  }

  @override
  String toString() {
    return '''FinishedOut{
      id: id,
      createDateStart: createDateStart,
      createDateEnd: createDateEnd,
      productorderno: productorderno,
      workshopId: workshopId,
      locationId: locationId,
      workOrderId: workOrderId,
      productName: productName,
      productCode: productCode,
      productstyle: productstyle,
      batchno: batchno,
      stockqty: stockqty,
      unitname: unitname,
      createUid: createUid,
      createDate: createDate,
      warehouseId: warehouseId,
      writeUid: writeUid,
      writeDate: writeDate,
      loaddate: loaddate,
      moveType: moveType,
    }''';
  }

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      (other is FinishedOut &&
          runtimeType == other.runtimeType &&
          id == other.id);

  factory FinishedOut.fromMap(Map<String, dynamic> map) {
    return new FinishedOut(
      id: map['id'] != false ? map['id'].toString() as String? : "",
      name: map['name'] != false ? map['name'].toString() as String? : "",
      productorderno: map['productorderno'] != false
          ? map['productorderno'].toString() as String?
          : "",
      batchno:
          map['batchno'] != false ? map['batchno'].toString() as String? : "",
      createUid: map['create_uid'][1] != false
          ? map['create_uid'][1].toString() as String?
          : "",
      createDate: map['create_date'] != false
          ? map['create_date'].toString() as String?
          : "",
      warehouseId: map['location_id'][1] != false
          ? map['location_id'][1].toString() as String?
          : "",
      locationName: map['location_id'][1] != false
          ? map['location_id'][1].toString() as String?
          : "",
      writeUid: map['write_uid'][1] != false
          ? map['write_uid'][1].toString() as String?
          : "",
      writeDate: map['write_date'] != false
          ? map['write_date'].toString() as String?
          : "",
      moveType: map['move_type'] != false
          ? map['move_type'].toString() as String?
          : "",
      dateDone: map['date_done'] != false
          ? map['date_done'].toString() as String?
          : "",
      loaddate:
          map['loaddate'] != false ? map['loaddate'].toString() as String? : "",
      contractid: map['contractid'] != false
          ? map['contractid'].toString() as String?
          : "",
      escortcode: map['escortcode'] != false
          ? map['escortcode'].toString() as String?
          : "",
      pickingTypeId: map['picking_type_id'][0] != false
          ? map['picking_type_id'][0].toString() as String?
          : "",
      pickingTypeName: map['picking_type_id'][1] != false
          ? map['picking_type_id'][1].toString() as String?
          : "",
      detaileds: map['move_line_ids'] != false && map['move_line_ids'].length!=0
          ? map['move_line_ids']
          : [],
    );
  }

  Map<String, dynamic> toMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'createDateStart': this.createDateStart,
      'createDateEnd': this.createDateEnd,
      'productorderno': this.productorderno,
      'workshopId': this.workshopId,
      'locationId': this.locationId,
      'workOrderId': this.workOrderId,
      'productName': this.productName,
      'productCode': this.productCode,
      'productstyle': this.productstyle,
      'batchno': this.batchno,
      'stockqty': this.stockqty,
      'unitname': this.unitname,
      'createUid': this.createUid,
      'createDate': this.createDate,
      'warehouseId': this.warehouseId,
      'writeUid': this.writeUid,
      'writeDate': this.writeDate,
      'loaddate': this.loaddate,
      'moveType': this.moveType,
    } as Map<String, dynamic>;
  }

  List toDomainList() {
    List list = [
      if (this.workOrderId != null && this.workOrderId != '')
        ['default_code@', 'like', '%${this.workOrderId}%'],
      if (this.productName != null && this.productName != '')
        ['name@', 'like', '%${this.productName}%'],
      if (this.locationId != null && this.locationId != '')
        ['location_id', '=', int.parse(this.locationId!)],
      if (this.workshopId != null && this.workshopId != '')
        ['workshop_id', '=', int.parse(this.workshopId!)],
      if (this.createDateStart != null && this.createDateStart != '')
        ['create_date', '>=', this.createDateStart!],
      if (this.createDateEnd != null && this.createDateEnd != '')
        ['create_date', '<=', this.createDateEnd!],
    ] as List;
    // ignore: unnecessary_cast
    return list;
  }

  Map<String, dynamic> toOdooMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'createDateStart': this.createDateStart,
      'createDateEnd': this.createDateEnd,
      'productorderno': this.productorderno,
      'workshopId': this.workshopId,
      'locationId': this.locationId,
      'workOrderId': this.workOrderId,
      'productName': this.productName,
      'productCode': this.productCode,
      'productstyle': this.productstyle,
      'batchno': this.batchno,
      'stockqty': this.stockqty,
      'unitname': this.unitname,
      'createUid': this.createUid,
      'createDate': this.createDate,
      'warehouseId': this.warehouseId,
      'writeUid': this.writeUid,
      'writeDate': this.writeDate,
      'loaddate': this.loaddate,
      'moveType': this.moveType,
    } as Map<String, dynamic>;
  }
}
